package com.wzy.xxgl.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import javax.sql.rowset.serial.SerialException;

import com.wzy.common.exception.ServiceException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wzy.common.annotation.Log;
import com.wzy.common.core.controller.BaseController;
import com.wzy.common.core.domain.AjaxResult;
import com.wzy.common.enums.BusinessType;
import com.wzy.xxgl.domain.XxglSxxx;
import com.wzy.xxgl.service.IXxglSxxxService;
import com.wzy.common.utils.poi.ExcelUtil;
import com.wzy.common.core.page.TableDataInfo;

/**
 * 实习信息Controller
 * 
 * @author wzy
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/xxgl/sxxx")
public class XxglSxxxController extends BaseController
{
    @Autowired
    private IXxglSxxxService xxglSxxxService;

    /**
     * 查询实习信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(XxglSxxx xxglSxxx)
    {
        startPage();
        List<XxglSxxx> list = xxglSxxxService.selectXxglSxxxList(xxglSxxx);
        return getDataTable(list);
    }

    /**
     * 导出实习信息列表
     */
    @Log(title = "实习信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XxglSxxx xxglSxxx)
    {
        List<XxglSxxx> list = xxglSxxxService.selectXxglSxxxList(xxglSxxx);
        ExcelUtil<XxglSxxx> util = new ExcelUtil<XxglSxxx>(XxglSxxx.class);
        util.exportExcel(response, list, "实习信息数据");
    }

    /**
     * 获取实习信息详细信息
     */
    @GetMapping(value = "/{sxxxId}")
    public AjaxResult getInfo(@PathVariable("sxxxId") Long sxxxId)
    {
        return success(xxglSxxxService.selectXxglSxxxBySxxxId(sxxxId));
    }

    /**
     * 根据导师ID查询对应实习的学生下拉框数据
     */
    @GetMapping("/getStudentDataByTeacherId/{teacherId}")
    public AjaxResult getStudentDataByTeacherId(@PathVariable("teacherId") Long teacherId)
    {
        List<XxglSxxx> list = xxglSxxxService.getStudentDataByTeacherId(teacherId);
        return success(list);
    }
    /**
     * 新增实习信息
     */
    @Log(title = "实习信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XxglSxxx xxglSxxx)
    {
        return toAjax(xxglSxxxService.insertXxglSxxx(xxglSxxx));
    }

    /**
     * 修改实习信息
     */
    @Log(title = "实习信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XxglSxxx xxglSxxx)
    {
        return toAjax(xxglSxxxService.updateXxglSxxx(xxglSxxx));
    }

    /**
     * 删除实习信息
     */
    @Log(title = "实习信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sxxxIds}")
    public AjaxResult remove(@PathVariable Long[] sxxxIds)
    {
        return toAjax(xxglSxxxService.deleteXxglSxxxBySxxxIds(sxxxIds));
    }
}
